package fr.demos.cinepantin.controleur;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import fr.demos.cinepantin.Article;
import fr.demos.cinepantin.LignePanier;
import fr.demos.cinepantin.Panier;

/**
 * Servlet implementation class Paiement
 */
@WebServlet("/Paiement")
public class Paiement extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Paiement() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		HttpSession session = request.getSession();	
		// on recupere le panier en session
		Panier panier = (Panier) session.getAttribute("panierSession");
		
		// on recupere la liste des articles de panier
		
		double montantTotalePaiement = panier.getMontantTotal();
		request.setAttribute("montantTotalePaiement", montantTotalePaiement);
		
		request.setAttribute("page", "/paiement.jsp");
		RequestDispatcher rd = request.getRequestDispatcher("/page.jsp");
		rd.forward(request, response);
	}

}
